/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package test;

import java.io.IOException;
import java.net.URL;
import java.util.List;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.htmlparser.jericho.Attribute;
import net.htmlparser.jericho.Element;
import net.htmlparser.jericho.HTMLElementName;
import net.htmlparser.jericho.Source;
import net.htmlparser.jericho.StartTag;
import net.htmlparser.jericho.TextExtractor;
import org.kiakaku.downloadpage.Node;
import org.kiakaku.downloadpage.OutLink;

/*
 *   File NewClass is created by kiakaku on Mar 13, 2012 11:26:19 PM
 * If you want modify this file please insert information in here 
 * - Last modify in Mar 13, 2012, 11:26:19 PM by kiakaku
 *                  
 *
 * @author kiakaku
 */
public class NewClass {

    public void get(Node site) {
        System.out.println("start Download 1 site");
        try {
            Source source = new Source(new URL(site.getUrl()));
            source.setLogger(null);
            List<Element> div = source.getAllElements(HTMLElementName.DIV);
            Element chi_tiet = null;
            for (Element temp : div) {
                if ("ctl00_IDContent_Tin_Chi_Tiet".equalsIgnoreCase(temp.getAttributeValue("id"))) {
                    chi_tiet = temp;
                    break;
                }
            }
            if (chi_tiet == null) {
                for (Element temp : div) {
                    if ("container".equalsIgnoreCase(temp.getAttributeValue("class"))) {
                        chi_tiet = temp;
                        break;
                    }
                }
            }
            TextExtractor txtExtract = new TextExtractor(chi_tiet) {

                @Override
                public boolean excludeElement(StartTag st) {
                    if (st.getName().equalsIgnoreCase(HTMLElementName.DIV) && "list-video-header".equalsIgnoreCase(st.getAttributeValue("class"))) {
                        return true;
                    }
                    return false;
                }
            };
            System.out.println("Download finish");
            System.out.println(txtExtract.toString());
        } catch (IOException ex) {
            Logger.getLogger(OutLink.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public static void main(String[] args) {
        String a = new String("abc");
        for (int i = 0; i < 100; i++) {
            System.out.println(a.hashCode());
        }
    }
}
